package com.hulk.ratel.manage.enums;

import com.google.common.base.Objects;

/**
 * Created by hulk on 2018/3/9.
 * 交易状态
 */
public enum TradeState {

    SUCCESS("SUCCESS", "支付成功"),
    REFUND("REFUND", "转入退款"),
    NOTPAY("NOTPAY", "未支付"),
    CLOSED("CLOSED", "已关闭"),
    REVOKED("REVOKED", "已撤销(刷卡支付)"),
    USERPAYING("USERPAYING", "用户支付中"),
    PAYERROR("PAYERROR", "支付失败(其他原因，如银行返回失败)"),;

    private String value;

    private String desc;

    TradeState(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static String explain(String value) {
        for (TradeState obj : TradeState.values()) {
            if (Objects.equal(value, obj.value)) {
                return obj.desc;
            }
        }
        return value;
    }

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return this.value;
    }
}
